package org.hawk.gwt.ppc.scanner;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.hawk.gwt.ppc.Configuration;
import org.hawk.gwt.ppc.GWTModule;
import org.hawk.gwt.ppc.ProcessingUnitsManager;
import org.hawk.gwt.ppc.javacc.JavaScanner;
import org.hawk.gwt.ppc.javacc.ParseException;
/**
 * Base interface for all task-related preprocessors.
 * Used and should be registered by {@link ProcessingUnitsManager}. 
 * @author alex.bereznevatiy@gmail.com
 *
 */
public interface ProcessingUnit {
	/**
	 * Configures this preprocessor. {@link ProcessingUnitsManager} follows 
	 * his contract to always call this method before run the actual preprocessing.
	 * @param config
	 * @param scanner
	 */
	void configure(Configuration config,JavaScanner scanner);
	/**
	 * Do preprocessing for the GWT module xml descriptor.
	 * @param module
	 * @throws IOException 
	 * @throws ParseException 
	 */
	void processModule(GWTModule module) throws IOException, ParseException;
	/**
	 * Do preprocessing for the GWT module entry point.
	 * @param entryPoint
	 * @param reader
	 * @param writer 
	 * @throws IOException 
	 * @throws ParseException 
	 */
	void processEntryPoint(String entryPoint, 
			Reader reader, Writer writer) throws IOException, ParseException;
	/**
	 * @param resource
	 * @return <code>true</code> if this preprocessor can and
	 * want to preprocess this resource. Otherwise returns <code>false</code>.
	 */
	boolean acceptResource(String resource);
}
